package com.baiyang.server.model;

import java.util.List;

import com.alibaba.fastjson.JSONObject;

// 分页查找使用的实体类
public class PageEntity<T> {
	private String result;
	private int pageStart;
	private int pageEnd;
	private int pageSize;
	private int pageOn;
	private String sort;
	private String orderBy;
	private T o;
	private List<T> datas;
	private Integer count;
	public PageEntity(){}
	@SuppressWarnings("unchecked")
	public PageEntity(JSONObject object) throws InstantiationException, IllegalAccessException{
		this.pageOn = object.getIntValue("pageOn");
		this.pageSize = object.getIntValue("pageSize");
		this.sort = object.getString("sort");
		this.orderBy = object.getString("orderBy");
		this.pageStart = (pageOn - 1) * pageSize;
		this.pageEnd = pageOn * pageSize - 1;
		this.o = (T) object.getObject("data", Object.class);
	}
	public int getPageStart() {
		return pageStart;
	}
	public void setPageStart(int pageStart) {
		this.pageStart = pageStart;
	}
	public int getPageEnd() {
		return pageEnd;
	}
	public void setPageEnd(int pageEnd) {
		this.pageEnd = pageEnd;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageOn() {
		return pageOn;
	}
	public void setPageOn(int pageOn) {
		this.pageOn = pageOn;
	}
	public T getO() {
		return o;
	}
	public void setO(T o) {
		this.o = o;
	}
	public List<T> getDatas() {
		return datas;
	}
	public void setDatas(List<T> datas) {
		this.datas = datas;
	}
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public String getSort() {
		return sort;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}
	public String getOrderBy() {
		return orderBy;
	}
	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
	
}
